<!--
 * @Author: Lu junwen
 * @Date: 2022-04-29 10:20:00
 * @LastEditors: Lu junwen
 * @LastEditTime: 2022-05-05 19:02:43
 * @FilePath: \vue-shop-app-customer\src\views\Goods\GoodsDetail.vue
-->
<template>
  <div class="goods_detail">
    <div class="header">
      <van-sticky>
        <van-nav-bar title="商品详情" left-text="返回" left-arrow @click-left="onClickLeft" />
      </van-sticky>
    </div>
    <div class="content">
      <div class="swipe">
        <van-swipe class="my-swipe" indicator-color="white" :height="250">
          <van-swipe-item v-for="image in good.pics" :key="image.pics_id">
            <img :src="image.pics_big_url" />
          </van-swipe-item>
        </van-swipe>
      </div>
      <div class="good_info">
        <div class="title">
          <div class="price">
            <span>￥</span>
            {{good.goods_price}}
          </div>
          <div class="name">{{good.goods_name}}</div>
        </div>
        <div class="attr">
          <van-collapse v-model="activeName" accordion>
            <van-collapse-item title="发货" name="1">
              <div class="send">
                <span>上海</span>
                <span>快递：免运费</span>
              </div>
            </van-collapse-item>
            <van-collapse-item title="保障" name="2">7天无理由</van-collapse-item>
            <van-collapse-item title="参数" name="3">
              <!-- <div class="good_attr" v-for="attr in good.attrs" :key="attr.attr_id">
                <div class="attr_name" style="width:100px">{{attr.attr_name}}</div>
                <div class="attr_value">{{attr.attr_value}}</div>
              </div> -->
              <van-cell center :title="attr.attr_name" :value="attr.attr_value" v-for="attr in good.attrs" :key="attr.attr_id" />
            </van-collapse-item>
          </van-collapse>
        </div>
        <div class="tip">——商品详情——</div>
        <div class="detail" v-html="good.goods_introduce">

        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Swipe, SwipeItem } from 'vant';
export default {
  data() {
    return {
      good: {},
      activeName: ['1']
    }
  },
  mounted() {
    this.getGoodData()
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    getGoodData() {
      this.axios.get(`goods/${this.$route.query.id}`).then(res => {
        console.log(res.data);
        this.good = res.data.data
      })
    }
  }
}
</script>

<style lang="scss">
.goods_detail {
  height: 100vh;
  padding-bottom: 50px;
  overflow: scroll;
  background-color: #f3f3f3;
  .content {
    .swipe {
      .my-swipe,
      .my-swipe img {
        width: 100%;
        height: 250px;
        // border-radius: 8px;
      }
    }
    .good_info {
      padding: 5px 8px;
      .title {
        padding: 10px 10px;
        margin-top: 5px;
        border-radius: 5px;
        background-color: #fff;
        .price {
          color: red;
          font-size: 25px;
          font-weight: 500;
          span {
            font-size: 15px;
          }
        }
        .name {
          margin-top: 10px;
          font-size: 22px;
        }
      }
      .attr {
        padding: 10px 10px;
        margin-top: 10px;
        border-radius: 5px;
        background-color: #fff;
        .send{
          span:first-child {
            padding-right: 20px;
            border-right: 2px solid #ccc;
          }
          span:nth-child(2) {
            padding-left: 20px;
          }
        }
        .good_attr{
          display: flex;
          div:first-child{
            padding-right: 10px;
          }
        }
      }
      .tip{
        margin: 5px 0;
        margin-top: 10px;
        text-align: center;
        font-size: 14px;
        color: #808080;
      }
      .detail{
        padding: 10px 10px;
        // margin-top: 10px;
        border-radius: 5px;
        background-color: #fff;
        p{
          img{
          width: 100%;
        }
        }
      }
    }
  }
}
::v-deep .van-cell__title{
  width: 50px;
}
</style>